package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.MarketAddress;
import com.cskaoyan.market.db.domain.MarketAddressExample;
import com.cskaoyan.market.db.mapper.MarketAddressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @Project:Project2
 * @Title:WxAddressServiceImpl
 * @Package:com.cskaoyan.market.service
 * @Author:Cl
 * @Date :2024/5/20 21:34
 */
@Service
public class WxAddressServiceImpl implements WxAddressService {
    @Autowired
    MarketAddressMapper addressMapper;

    @Override
    public List<Object> list() {
        List<MarketAddress> marketAddresses = addressMapper.selectByExample(new MarketAddressExample());
        ArrayList<Object> arrayList = new ArrayList<>(marketAddresses);
        return arrayList;
    }

    @Override
    public MarketAddress detail(Integer id) {
        return addressMapper.selectByPrimaryKey(id);
    }

    @Override
    public Object update(MarketAddress marketAddress) {
        return addressMapper.updateByPrimaryKey(marketAddress);
    }

    @Override
    public Object create(MarketAddress marketAddress) {
        marketAddress.setAddTime(LocalDateTime.now());
        marketAddress.setUpdateTime(LocalDateTime.now());
        return addressMapper.insert(marketAddress);
    }

    @Override
    public void delete(Integer id) {
        addressMapper.deleteByPrimaryKey(id);
    }


}
